using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace zeroflag.Windows.Custom
{
	public partial class CustomController<ViewType> :
		ACustomController,
		ICustomController<ViewType>
		where ViewType : ACustomView
	{
		public CustomController()
			: this(null)
		{
		}

		public CustomController(ViewType view)
		{
			this.View = view;
			InitializeComponent();
		}

		public override RenderTarget RenderTarget
		{
			get { return this.View.RenderTarget; }
		}

		ViewType m_View;
		public virtual ViewType View
		{
			get { return m_View; }
			set
			{
				if (m_View != value && value != null)
				{
					m_View = value;
					if (m_View.GetController() != this)
						m_View.SetController(this);
				}
			}
		}

		//public new ViewType View
		//{
		//    get { return this.GetView(); }
		//    set { this.SetView((ViewType)value); }
		//}

		protected internal override ACustomView GetView()
		{
			return (ACustomView)this.View;
		}

		protected internal override void SetView(ACustomView value)
		{
			this.View = (ViewType)value;
		}

		public override void Render(RenderArea renderArea)
		{
		}
	}
}
